﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="branchUC.ascx.cs" Inherits="ERP.PageUC.branchUC" %>
<script>
    function DetailRowsBranch(x) {
        //gets table
        var getTable = document.getElementById('MyTableBranch');
        //gets cells of current row  
        var getCells = getTable.rows.item(x.rowIndex).cells;

        document.getElementById('<%=lbID.ClientID %>').value = getCells.item(0).innerHTML;
        document.getElementById('<%=txtMaChiNhanh.ClientID %>').disabled = true;
        document.getElementById('<%=txtMaChiNhanh.ClientID %>').value = getCells.item(2).innerHTML;
        document.getElementById('<%=txtTenChiNhanh.ClientID %>').value = getCells.item(3).innerHTML;
        document.getElementById('<%=txtGhiChu.ClientID %>').value = getCells.item(4).innerHTML;
        $("#chinhanh").dialog("open");
    };
    function CheckSaveBranch() {
        var kt1 = $('#<%=txtMaChiNhanh.ClientID %>');
        var kt2 = $('#<%=txtTenChiNhanh.ClientID %>');
        var allFields = $([]).add(kt1).add(kt2);
        var valid;
        allFields.removeClass("ui-state-error");
        valid = checkLength(kt1, "Mã chi nhánh", 1, 50);
        valid = valid && checkLength(kt2, "Tên chi nhánh", 1, 50);
        if (valid) {
            updateTips('');
            allFields.removeClass("ui-state-error");
        }
        return valid;
    };
</script>
<asp:UpdatePanel ID="upDateAll" runat="server">
    <ContentTemplate>
        <!---------------Toolbar---------------->
        <div class="toolbar-main">
            <button id="btnAdd" class="btn btn-default btn-sm" title="Thêm mới" onclick="return Show('#chinhanh');"><span class="glyphicon glyphicon-pencil"></span>Thêm mới</button>
            <asp:LinkButton ID="btnDelete" CssClass="btn btn-default btn-sm" title="Xóa" runat="server" OnClientClick="return confirmCheckIn(this)" OnClick="btnDelete_Click"><span class="glyphicon glyphicon-trash"></span> Xoá</asp:LinkButton>
            <asp:LinkButton ID="btnExcel" CssClass="btn btn-default btn-sm" title="Xuất file Excel" runat="server"><span class="glyphicon glyphicon-print"></span> Xuất file Excel</asp:LinkButton>
        </div>
        <!---------------Toolbar---------------->
        <%=StrAlert %>
        <!----------------Loading---------------->
        <asp:UpdateProgress ID="upDateProcess" runat="server" AssociatedUpdatePanelID="upDateAll">
            <ProgressTemplate>
                <span style="text-align: center" class="label label-warning">Đang tải...</span>
            </ProgressTemplate>
        </asp:UpdateProgress>
        <!--------------Kêt-thúc----------------->
        <!-------------Hiễn-Dữ-Liệu-------------->
        <div class="table-responsive">
            <asp:ListView ID="ListViewAll" runat="server" DataKeyNames="STT">
                <LayoutTemplate>
                    <table id="MyTableBranch" class="tablesorter">
                        <thead>
                            <tr>
                                <th style="text-align: center" data-sorter="false" data-filter="false">STT</th>
                                <th style="text-align: center" data-sorter="false" data-filter="false">
                                    <input type="checkbox" onchange="checkAll()" id="chkAll" />
                                </th>
                                <th style="text-align: center" class="filter-select" data-placeholder="--Chọn mã chi nhánh--">Mã chi nhánh</th>
                                <th style="text-align: center" class="filter-select" data-placeholder="--Chọn tên chi nhánh--">Tên chi nhánh</th>
                                <th style="text-align: center" data-sorter="false" data-filter="false">Ghi chú</th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr id="itemPlaceholder" runat="server">
                            </tr>
                        </tbody>
                    </table>
                </LayoutTemplate>
                <ItemTemplate>
                    <tr runat="server" ondblclick="DetailRowsBranch(this)" class="warning">
                        <td style="text-align: center"><%# Eval("STT") %></td>
                        <td style="text-align: center">
                            <asp:CheckBox ClientIDMode="Static" ID="chkList" runat="server" />
                        </td>
                        <td><%# Eval("MACHINHANH") %></td>
                        <td><%# Eval("TENCHINHANH") %></td>
                        <td><%# Eval("GHICHU") %></td>
                    </tr>
                </ItemTemplate>
                <EmptyDataTemplate>
                    <div class='alert alert-danger'>
                        <a href='#' class='close' data-dismiss='alert'>&times;</a>
                        Không tìm thấy mẫu tin nào !
                    </div>
                </EmptyDataTemplate>
            </asp:ListView>
        </div>
        <div class="pager MyTableBranch">
            <div class="toolbar-main">
                <asp:LinkButton ID="btnReload" CssClass="btn btn-default btn-xs glyphicon glyphicon glyphicon-retweet" title="Tải lại" runat="server" OnClick="btnReload_Click"></asp:LinkButton>
                &nbsp;
                    <asp:TextBox ID="txtSearch" CssClass="textbox-search" runat="server" />
                <asp:LinkButton ID="btnSearch" CssClass="btn btn-default btn-xs glyphicon glyphicon glyphicon-search" title="Tìm kiếm" runat="server" OnClick="btnSearch_Click"></asp:LinkButton>
                &nbsp;            
                    <span>Trang</span>
                <select class="gotoPage" title="Select page number"></select>
                <img src="../Content/TableSort/addons/pager/icons/first.png" class="first" alt="First" />
                <img src="../Content/TableSort/addons/pager/icons/prev.png" class="prev" alt="Prev" />
                <span class="pagedisplay"></span>
                <img src="../Content/TableSort/addons/pager/icons/next.png" class="next" alt="Next" />
                <img src="../Content/TableSort/addons/pager/icons/last.png" class="last" alt="Last" />
            </div>
        </div>
    </ContentTemplate>
    <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnDelete" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="btnReload" EventName="Click" />
    </Triggers>
</asp:UpdatePanel>
<!-------------Edit-Dữ-Liệu-------------->
<div id="chinhanh" title="Cập nhật chi nhánh">
    <asp:UpdatePanel ID="upNewUpdatePanel" UpdateMode="Conditional" ChildrenAsTriggers="true" runat="server">
        <ContentTemplate>
            <div class="btn-toolbar">
                <asp:Button ID="btnSavePopup" CssClass="btn-save btn-default" title="Lưu lại" runat="server" OnClientClick="return CheckSaveBranch();" OnClick="btnSavePopup_Click" />
                &nbsp;
            <asp:Button ID="btnReloadPopup" CssClass="btn-reload btn-default" title="Tải lại" runat="server" OnClick="btnReloadPopup_Click" />
                &nbsp;
            <input type="hidden" id="lbID" runat="server" /><label class="validateTips"></label>
                <asp:UpdateProgress ID="upDateProcessUC" runat="server" AssociatedUpdatePanelID="upNewUpdatePanel">
                    <ProgressTemplate>
                        <span class="label label-warning">Đang tải..</span>
                    </ProgressTemplate>
                </asp:UpdateProgress>
            </div>
            <div class="ui-main">
                <div class="ui-box-text-box">
                    <label class="labelpopup">Mã chi nhánh <span style="color: Red">(*)</span></label>
                    <br />
                    <asp:TextBox ID="txtMaChiNhanh" CssClass="textbox-muiti" runat="server" data-allow="add"></asp:TextBox>
                </div>
                <div class="clr"></div>
                <div class="ui-box-text-box">
                    <label class="labelpopup">Tên chi nhánh <span style="color: Red">(*)</span></label>
                    <br />
                    <asp:TextBox ID="txtTenChiNhanh" CssClass="textbox-muiti" runat="server"></asp:TextBox>
                </div>
                <div class="clr"></div>
                <div class="ui-box-text-box">
                    <label class="labelpopup" style="text-align: center">
                        Ghi chú 
                    </label>
                    <br />
                    <asp:TextBox ID="txtGhiChu" CssClass="textbox-muiti" runat="server" TextMode="MultiLine"></asp:TextBox>
                </div>
                <div class="clr"></div>
            </div>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSavePopup" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
</div>
<!--------------Kêt-thúc----------------->
